package com.iot08.api.service;

import com.iot08.common.entity.app.BloodPressureSetting;
import com.iot08.common.entity.app.HeartRateSetting;
import com.iot08.common.service.base.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @version 1.0
 * @Description:
 * @author: Rock
 * @time: 2021/3/8 18:33
 */
@Slf4j
@Service
public class BloodPressureSettingService extends BaseService<BloodPressureSetting> {

    /**
     * 获取记录，没有记录则添加默认记录
     *
     * @param id
     * @param openid
     * @time: 2021/3/8 19:37
     * @author: Rock
     * @version 1.0
     */
    public BloodPressureSetting getById(String id, String openid) {
        BloodPressureSetting bloodPressureSetting = this.findById(id);
        if (bloodPressureSetting == null) {
            bloodPressureSetting = new BloodPressureSetting();
            bloodPressureSetting.setId(id);
            bloodPressureSetting.setSetChangeTime(System.currentTimeMillis() / 1000);
            bloodPressureSetting.setSetFrequency(-1);
            bloodPressureSetting.setOpenid(openid);
            this.save(bloodPressureSetting);
        }
        return bloodPressureSetting;
    }

}
